﻿@using NigiriClub.WebUI.Models
@model NigiriClub.WebUI.Models.Account

@{
    ViewBag.Title = "Edit";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@{Account loggedIn = Account.GetAccount(User.Identity.Name);}

<div class="row">
    <div class="col-lg-4" style="height: 200px; width: 200px">
        <img src="/Content/images/avatars/@Model.Avatar" class="img-circle" style="height: 100%"/>
    </div>
    <div class="col-lg-8">
        @using (Html.BeginForm("UploadAvatar", "Profile", @Model, FormMethod.Post, new { enctype = "multipart/form-data" }))
        {
            @Html.AntiForgeryToken()
            <span class="input-group">
                <span class="input-group-btn">
                    <span class="file-input btn btn-primary btn-file btn-xs">Выбрать изображение
    @Html.TextBoxFor(model => model.AvatarFile.file, new { type = "file", accept = "image/*", @required = "true" })
                    </span>
                </span>
                <input type="text" class="form-control" readonly>
            </span>
            <button type="submit" class="btn btn-primary btn-xs">Загрузить</button>
        }
    </div>
</div>


<div class="row">
    @using (Html.BeginForm("EditSubmit", "Profile", @Model, FormMethod.Post, new { @class = "form-horizontal" }))
    {
        <fieldset>
            <div class="form-group">
                <label for="inputEmail" class="col-lg-2 control-label">Логин</label>
                <div class="col-lg-10">
                    @Model.Name
                </div>
            </div>
            @{ bool isUserTheSame = loggedIn == null ? false : loggedIn.Name == Model.Name;}
            <div class="form-group">
                <label for="inputPassword" class="col-lg-2 control-label">Полное имя</label>
                <div class="col-lg-10">
                    @if (isUserTheSame)
                    {
                        @Html.TextBoxFor(m => m.FullName, new { @class = "form-control", @required = "true" })
                    }
                    else
                    {
                        @Model.FullName
                    }
                </div>
            </div>
            <div class="form-group">
                <label for="inputLevel" class="col-lg-2 control-label">Рейтинг РФГ</label>
                <div class="col-lg-10">
                    @if (loggedIn != null && loggedIn.PermissionId == 2)
                    {
                        @Html.TextBoxFor(m => m.Level, new { @class = "form-control", @required = "true", @pattern = "\\d{1,4}" })
                    }
                    else
                    {
                        @Model.Level
                    }
                </div>
            </div>
            @if (isUserTheSame || loggedIn != null && loggedIn.PermissionId == 2)
            {
                <div class="col-lg-10 col-lg-offset-2">
                    @*<button class="btn btn-default">Cancel</button>*@
                    <button type="submit" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-floppy-disk"></span>Сохранить</button>
                </div>
            }
        </fieldset>
    }

</div>
